<template>
  <div class="dashboard-container">
    <div class="app-container">
      <!-- 自定义组件，标题 -->
      <PageTitle :show-before="true">
        <template v-slot:before>
          <h2>短链接列表</h2>
        </template>
      </PageTitle>
      <!-- 数据表 -->
      <el-table
        v-loading="downloadLoading"
        ooltip-effect="dark"
        :data="list"
        max-height="500px"
        style="margin-top: 20px"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55" fixed />
        <el-table-column
          label="短码"
          align="center"
          width="60"
          prop="code"
          fixed
        />
        <el-table-column label="备注" align="center" prop="remark" fixed />
        <el-table-column
          label="到期时间"
          align="center"
          prop="endtime"
          width="130"
          fixed
        />
        <el-table-column
          label="创建时间"
          align="center"
          prop="school"
          width="180"
        >
          <template slot-scope="scope">
            <i class="el-icon-time"></i> {{ scope.row.addtime }}
          </template>
        </el-table-column>
        <el-table-column label="创建者" align="center" prop="pv">
          <template slot-scope="scope">
            {{ scope.row.pv ? "" : "系统" }}
          </template>
        </el-table-column>
        <el-table-column
          header-align="center"
          align="center"
          prop="prop"
          label="操作"
          width="350"
        >
          <el-button
            type="primary"
            size="small"
            @click="editShortLinkDialog = true"
            >编辑</el-button
          >
          <el-button size="small" @click="qrCodeDialog = true"
            >二维码</el-button
          >
          <el-button size="small">复制链接</el-button>
          <el-button type="danger" size="small" @click="delBtn">删除</el-button>
        </el-table-column>
      </el-table>
      <el-row :gutter="10" style="margin-top: 20px">
        <el-col :span="8">
          <el-button
            type="primary"
            size="small"
            @click="addShortLinkDialog = true"
            >添加</el-button
          >
          <el-button type="danger" size="small" @click="delBtns"
            >删除</el-button
          >
        </el-col>
        <el-col :span="16">
          <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage4"
            :page-sizes="[10, 20, 50, 100]"
            :page-size="10"
            layout="total, sizes, prev, pager, next, jumper"
            :total="255"
            style="text-align: right"
          >
          </el-pagination>
        </el-col>
      </el-row>
    </div>
    <addShortLink :addShortLinkDialog.sync="addShortLinkDialog" />
    <editShortLink :editShortLinkDialog.sync="editShortLinkDialog" />
    <qrCode :qrCodeDialog.sync="qrCodeDialog" />
  </div>
</template>

<script>
import addShortLink from "@/views/tool/shortLink/shortLinkBelow/components/addShortLink";
import editShortLink from "@/views/tool/shortLink/shortLinkBelow/components/editShortLink";
import qrCode from "@/views/tool/shortLink/shortLinkBelow/components/qrCode";
export default {
  components: {
    addShortLink,
    editShortLink,
    qrCode,
  },
  data() {
    return {
      addShortLinkDialog: false,
      editShortLinkDialog: false,
      qrCodeDialog: false,
      list: [
        {
          id: 138,
          url: "http:\/\/hr.blwang.com\/m\/job\/1203",
          code: "hL",
          addtime: 1730270238,
          endtime: 0,
          pv: 0,
          admin_id: 0,
          remark: "系统生成触屏版职位详情短链",
          admin_name: null,
        },
        {
          id: 137,
          url: "http:\/\/hr.blwang.com\/m\/job\/911",
          code: "R8",
          addtime: 1729682788,
          endtime: 0,
          pv: 0,
          admin_id: 0,
          remark: "系统生成触屏版职位详情短链",
          admin_name: null,
        },
        {
          id: 136,
          url: "http:\/\/hr.blwang.com\/m\/job\/913",
          code: "Qj",
          addtime: 1729682664,
          endtime: 0,
          pv: 0,
          admin_id: 0,
          remark: "系统生成触屏版职位详情短链",
          admin_name: null,
        },
        {
          id: 135,
          url: "http:\/\/hr.blwang.com\/m\/job\/1124",
          code: "vd",
          addtime: 1729643929,
          endtime: 0,
          pv: 10,
          admin_id: 0,
          remark: "系统生成触屏版职位详情短链",
          admin_name: null,
        },
        {
          id: 134,
          url: "http:\/\/hr.blwang.com\/m\/job\/1206",
          code: "DL",
          addtime: 1728721324,
          endtime: 0,
          pv: 0,
          admin_id: 0,
          remark: "系统生成触屏版职位详情短链",
          admin_name: null,
        },
        {
          id: 133,
          url: "http:\/\/hr.blwang.com\/m\/job\/633",
          code: "GI",
          addtime: 1728357478,
          endtime: 0,
          pv: 0,
          admin_id: 0,
          remark: "系统生成触屏版职位详情短链",
          admin_name: null,
        },
        {
          id: 132,
          url: "http:\/\/hr.blwang.com\/m\/job\/388",
          code: "2q",
          addtime: 1727444177,
          endtime: 0,
          pv: 4,
          admin_id: 0,
          remark: "系统生成触屏版职位详情短链",
          admin_name: null,
        },
        {
          id: 131,
          url: "http:\/\/hr.blwang.com\/m\/job\/1209",
          code: "fd",
          addtime: 1726815752,
          endtime: 0,
          pv: 1,
          admin_id: 0,
          remark: "系统生成触屏版职位详情短链",
          admin_name: null,
        },
        {
          id: 130,
          url: "http:\/\/hr.blwang.com\/m\/job\/939",
          code: "O5",
          addtime: 1726016486,
          endtime: 0,
          pv: 2,
          admin_id: 0,
          remark: "系统生成触屏版职位详情短链",
          admin_name: null,
        },
        {
          id: 129,
          url: "http:\/\/hr.blwang.com\/m\/job\/1024",
          code: "S8",
          addtime: 1726016430,
          endtime: 0,
          pv: 3,
          admin_id: 0,
          remark: "系统生成触屏版职位详情短链",
          admin_name: null,
        },
      ],
    };
  },
  methods: {
    delBtn() {
      this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    delBtns() {
      this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.$message({
            type: "success",
            message: "删除成功!",
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
  },
};
</script>

<style lang="scss" scoped></style>
